//
// Created by 86131 on 2023/12/18.
//
#include <iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
    stack<string> c;
    string str;
    while(1){
        getline(cin,str);
        str = str +"~";
        if(str[0]=='.'&&str[1]=='~')break;
        for(int i=0;str[i]!='~';i++){
            if(str[i]=='{'){c.push("{");continue;}
            if(str[i]=='['){c.push("[");continue;}
            if(str[i]=='('){c.push("(");continue;}
            if(str[i]=='/'&&str[i+1]=='*'){c.push("/*");i=i+1;continue;}
            if(str[i]=='}'){
                if(!c.empty()&&c.top()=="{"){c.pop();continue;}
                else{
                    if(c.empty()){cout<<"NO"<<endl<<"?-}"<<endl;}
                    else {cout<<"NO"<<endl<<c.top()<<"-?"<<endl;}
                    return 0;
                }
            }
            if(str[i]==']'){
                if(!c.empty()&&c.top()=="["){c.pop();continue;}
                else{
                    if(c.empty()){cout<<"NO"<<endl<<"?-]"<<endl;}
                    else {cout<<"NO"<<endl<<c.top()<<"-?"<<endl;}
                    return 0;
                }
            }
            if(str[i]==')'){
                if(!c.empty()&&c.top()=="("){c.pop();continue;}
                else{
                    if(c.empty()){cout<<"NO"<<endl<<"?-)"<<endl;}
                    else {cout<<"NO"<<endl<<c.top()<<"-?"<<endl;}
                    return 0;
                }
            }
            if(str[i]=='*'&&str[i+1]=='/'){
                i=i+1;
                if(!c.empty()&&c.top()=="/*"){c.pop();continue;}
                else{
                    if(c.empty()){cout<<"NO"<<endl<<"?-*/"<<endl;}
                    else {cout<<"NO"<<endl<<c.top()<<"-?"<<endl;}
                    return 0;
                }
            }
        }
    }
    if(c.empty()){cout<<"YES"<<endl;}
    else cout<<"NO"<<endl<<c.top()<<"-?"<<endl;
    return 0;
}

